//
//  ItemInfo.m
//  ProjectL
//
//  Created by Nguyen Tan Loc on 11/22/13.
//  Copyright (c) 2013 Nguyen Tan Loc. All rights reserved.
//

#import "ItemInfo.h"

@implementation ItemInfo
+(ItemInfo *) getInstance
{
    static ItemInfo *mInstance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        mInstance = [[ItemInfo alloc] init];
    });
    
    return mInstance;
}

-(int) getItemPrice:(ITEM_TYPE)type
{
    switch (type)
    {
        case eIT_SHIELD:
            return PRICE_ITEM_SHIELD;
            
        case eIT_MAGNET:
            return PRICE_ITEM_MAGNET;
            
        case eIT_TIMER:
            return PRICE_ITEM_TIMER;
            
        case eIT_XRAY:
            return PRICE_ITEM_XRAY;
            
        default:
            return 0;
            break;
    }
}

-(NSString *) getItemPriceText:(ITEM_TYPE)type
{
    return [NSString stringWithFormat:@"Price: %d", [self getItemPrice:type]];
}

-(NSString *) getItemDesc:(ITEM_TYPE)type
{
    switch (type)
    {
        case eIT_SHIELD:
            return @"Protect you from bomb, lazer, ...";
            
        case eIT_MAGNET:
            return @"Increase range to collect energy";
            
        case eIT_TIMER:
            return @"Add 10s to level";
            
        case eIT_XRAY:
            return @"Remove dark fog";
            
        default:
            return @"";
            break;
    }
}

-(NSString *) getItemName:(ITEM_TYPE)type
{
    switch (type)
    {
        case eIT_SHIELD:
            return @"Shield";
            
        case eIT_MAGNET:
            return @"Magnet";
            
        case eIT_TIMER:
            return @"Timer";
            
        case eIT_XRAY:
            return @"Sun";
            
        default:
            return @"";
            break;
    }
}

-(CCSprite *) getItemSprite:(ITEM_TYPE)type
{
    switch (type)
    {
        case eIT_SHIELD:
            return [CCSprite spriteWithSpriteFrameName:SFN_ITEM_SHIELD_BIG];
            
        case eIT_MAGNET:
            return [CCSprite spriteWithSpriteFrameName:SFN_ITEM_MAGNET_BIG];
            
        case eIT_TIMER:
            return [CCSprite spriteWithSpriteFrameName:SFN_ITEM_TIME_BIG];
            
        case eIT_XRAY:
            return [CCSprite spriteWithSpriteFrameName:SFN_ITEM_XRAY_BIG];
            
        default:
            return [CCSprite spriteWithSpriteFrameName:SFN_ICON_REPLAY];
            break;
    }
}

-(NSString *) getPacketDesc:(IAP_TYPE)type
{
    return [NSString stringWithFormat:@"Contain: %d", [self getPacketNum:type]];
}

-(NSString *) getPacketName:(IAP_TYPE)type
{
    switch (type) {
        case eIAP_TINY:
            return @"Tiny gold packet";
        case eIAP_SMALL:
            return @"Small gold packet";
        case eIAP_MEDIUM:
            return @"Medium gold packet";
        case eIAP_LARGE:
            return @"Large gold packet";
            
        default:
            return @"";
    }
}

-(NSString *) getPacketPriceText:(IAP_TYPE)type
{
    return [NSString stringWithFormat:@"Price: $%.2f", [self getPacketPrice:type]];
}

-(CCSprite *) getPacketSprite:(IAP_TYPE)type
{
    switch (type) {
        case eIAP_TINY:
            return [CCSprite spriteWithSpriteFrameName:SFN_ICON_GOLD_TINY];
        case eIAP_SMALL:
            return [CCSprite spriteWithSpriteFrameName:SFN_ICON_GOLD_SMALL];
        case eIAP_MEDIUM:
            return [CCSprite spriteWithSpriteFrameName:SFN_ICON_GOLD_MEDIUM];
        case eIAP_LARGE:
            return [CCSprite spriteWithSpriteFrameName:SFN_ICON_GOLD_LARGE];
            
        default:
            return nil;
    }
}

-(float) getPacketPrice:(IAP_TYPE)type
{
    switch (type) {
        case eIAP_TINY:
            return PRICE_GOLD_TINY;
        case eIAP_SMALL:
            return PRICE_GOLD_SMALL;
        case eIAP_MEDIUM:
            return PRICE_GOLD_MEDIUM;
        case eIAP_LARGE:
            return PRICE_GOLD_LARGE;
            
        default:
            return 0;
    }
}

-(int) getPacketNum:(IAP_TYPE)type
{
    switch (type) {
        case eIAP_TINY:
            return NUM_GOLD_PACKET_TINY;
        case eIAP_SMALL:
            return NUM_GOLD_PACKET_SMALL;
        case eIAP_MEDIUM:
            return NUM_GOLD_PACKET_MEDIUM;
        case eIAP_LARGE:
            return NUM_GOLD_PACKET_LARGE;
            
        default:
            return 0;
    }
}

@end
